
<table id="term_list" class="itable">
  <thead>
    <tr>
      <th width="3%">编号</th>
	  <th width="15%">标题</th>
	  <th width="3%">展示图片</th>
	  <th width="3%">大图片</th>
	  <th width="6%">店铺昵称</th>
	  <th width="3%">销量</th>
	  <th width="6%">价格</th>   
	  <th width="6%">折扣</th>   
	  <th width="6%">来源平台</th>
	  <th width="6%">类别</th>    
	  <th width="6%">颜色</th>
	  <th width="3%">喜爱度</th> 
	  <th width="6%">状态</th>
	  <th width="6%">用户</th>
	  <th width="6%">添加时间</th>
	  <th>操作</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td colspan="15" class="dataTables_empty">Loading...</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th width="3%">编号</th>
	  <th width="15%"><input type="text" value="标题" class="search_init"/></th>
	  <th width="3%">小图</th>
	  <th width="3%">大图</th>
	  <th width="6%">店铺昵称</th>
	  <th width="3%">销量</th>
	  <th width="6%">价格</th>   
	  <th width="6%">折扣</th>   
	  <th width="6%"><input type="text" value="商品来源id" class="search_init"/></th>
	  <th width="6%">类别</th>    
	  <th width="6%">颜色</th>
	  <th width="3%">喜爱度</th> 
	  <th width="6%">状态</th>
	  <th width="6%">用户</th>
	  <th width="6%">添加时间</th>
	  <th>操作</th>
    </tr>
  </tfoot>
</table>
<script type="text/javascript">
var termsTable = $("#term_list").dataTable({
  "bServerSide": true,
  "sAjaxSource": "admin.php?ctrl=product&act=items_data",
  "oLanguage": {
    "sUrl": "style/js/dt_cn.txt"
  },
  "aaSorting": [
	[ 0, "desc" ]
  ],
  //"bStateSave": true,//状态保存在cookie中
  "sPaginationType": "full_numbers",
  "aoColumns": [
    null,
	{ "asSorting": false },
	{ "asSorting": false },
	{ "asSorting": false },
	{ "asSorting": false },
	null,
	null,
	null,
	{ "asSorting": false },
	{ "asSorting": false },
	{ "asSorting": false },
	null,
	null,
	null,
	null,
	{ "asSorting": false }	
  ]
});
var asInitVals = new Array();
$("tfoot input").each( function (i) {
    asInitVals[i] = this.value;
} );
$("tfoot input").focus( function () {
    if ( this.className == "search_init" )
    {
        this.className = "";
        this.value = "";
    }
} );
 
$("tfoot input").blur( function (i) {
    if ( this.value == "" )
    {
        this.className = "search_init";
        this.value = asInitVals[$("tfoot input").index(this)];
    }
} );
$("tfoot input").keyup( function (e) {
    /* Filter on the column (the index) of this element */
    if(e.keyCode == 13){
    	termsTable.fnFilter( this.value, $("tfoot input").index(this) );
    }
    
} );
function del_product(pid){
	if(confirm('确定删除产品?')){
		$.ajax({
	      type: "POST",
	      url: "admin.php?ctrl=product&act=delete",
	      data: "pid="+pid,
	      timeout: 20000,
	      error: function(){alert('error');},
	      success: function(result){
	        if(result == '1'){
	        	$('#product_tabs').tabs( "load" , 0 );
	        }else if(result == '-1'){
	          alert('删除失败');
	        }else if(result == '-2'){
	          alert('不存在的产品');
	        }else{
	        	alert('未知错误'+result);
	        }
	      }
	    });
	}
}
function edit_product(pid){
	$product_tabs.tabs( "url" , 1 , "admin.php?ctrl=product&act=edit&pid="+pid );
	$product_tabs.tabs( "select" , 1 );
	//$product_tabs.tabs( "add", "admin.php?ctrl=product&act=edit&pid="+pid, '编辑产品'+pid );
}
$( "#product_tabs span.ui-icon-close" ).die().live( "click", function() {
	var index = $( "li", $product_tabs ).index( $( this ).parent() );
	$product_tabs.tabs( "remove", index );
});
</script>